#ifndef _LED_H_
#define _LED_H_

#include "driver/gpio.h"
#include <mutex>
#include "esp_timer.h"
#include "sdkconfig.h"

#define BLINK_INFINITE  -1


class Led {
public:
	Led(gpio_num_t pin, bool invert_out=false);
	~Led();
	virtual void BlinkOnce();
    virtual void Blink(int times, int interval_ms);
    virtual void StartContinuousBlink(int interval_ms);
    virtual void TurnOn();
    virtual void TurnOff();
private:
	std::mutex	m_mutex;
	gpio_num_t	m_led;
#if CONFIG_EN_LUM_JUSTIFY
	int 	m_luminance = 0;
#endif
	bool 	m_invert_out = false;
	int		m_blink_counter = 0;
	int 	m_blink_interval_ms = 0;
	esp_timer_handle_t m_blink_timer = nullptr;

	void OnBlinkTimer();
	void StartBlinkTask(int times, int m_blink_interval_ms);
	
};


#endif
